<template>
  <div class="auto">
    <data-grid :model="model" partial='list' v-ref:grid>
      <template partial='head'>
        <tr>
          <th>序号</th>
          <th>气表型号</th>
          <th>大小卡</th>
          <th>表型号对应类型</th>
          <th>额定流量</th>
          <th>海力表型编码</th>
          <th>气表编号</th>
          <th>使用户数</th>
        </tr>
      </template>
      <template partial='body'>
       <tr>
         <td style="text-align:center">{{$index+1}}</td>
         <td style="text-align:center">{{row.f_meter_style}}</td>
         <td style="text-align:center">{{row.f_size_card}}</td>
         <td style="text-align:center">{{row.f_type}}</td>
         <td style="text-align:center">{{row.f_rated_traffic}}</td>
         <td style="text-align:center">{{row.f_coding}}</td>
         <td style="text-align:center">{{row.f_gasbrand_id}}</td>
         <td style="text-align:center">{{row.counts}}</td>
       </tr>
     </template>
     <template partial='foot'></template>
   </data-grid>
  </div>
</template>

<script>
import { HttpResetClass } from 'vue-client'
/**
*气表品牌相关信息组件
*/

export default {
  props: ['data'],
  data () {
    return {
      model: {
        rows: []
      }
    }
  },
  watch: {
    'data' (val) {
      if (!this.isEmpty(val)) {
        this.f_gasbrand_id = val.id
        this.getUpdate()
      }
    }
  },
  ready () {
    if (!this.isEmpty(this.data)) {
      this.f_gasbrand_id = this.data.id
      this.getUpdate()
    }
  },
  methods: {
    getUpdate () {
      let condition = 'g.f_gasbrand_id=' + "'" + this.f_gasbrand_id + "'"
      let http = new HttpResetClass()
        http.load('POST', 'rs/sql/getModels',{data: {condition: condition}}, {resolveMsg: null, rejectMsg: null}).then((res) => {
         this.model.rows = res.data
       }).catch ((error) => this.$dispatch('error', '气表品牌相关信息', this.data, error))
      // let tablename = 't_gasmodel'
      // let condition = 'f_gasbrand_id=' + "'" + this.f_gasbrand_id + "'"
      // this.$SqlService.singleTable(tablename, condition)
      // .then(
      //   (res) => {
      //     this.model.rows = res.data
      //   }
      // ).catch(
      //   (error) => this.$dispatch('error', '气表品牌相关信息', this.data, error)
      // )
    },
    isEmpty (value) {
      for (let name in value) {
        return false
      }
      return true
    }
  }
}
</script>
<style>

</style>
